﻿using System;
using System.Collections.Generic;
using System.Text;
using Barbar.Colonization.Core;

namespace Barbar.Colonization.Model {
  public struct Coordinate {
    private int m_X;
    private int m_Y;

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "X")]
    public int X {
      get { return m_X; }
      set { m_X = value; }
    }

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Y")]
    public int Y {
      get { return m_Y; }
      set { m_Y = value; }
    }

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "x"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "y")]
    public Coordinate(int x, int y) {
      m_X = x;
      m_Y = y;
    }

    public override int GetHashCode() {
      return m_X ^ m_Y;
    }

    public override bool Equals(object obj) {
      if (!(obj is Coordinate))
        return false;
      return Equals((Coordinate)obj);
    }

    private bool Equals(Coordinate coordinate) {
      return coordinate.m_X == m_X && coordinate.m_Y == m_Y;
    }

    public static bool operator ==(Coordinate first, Coordinate second) {
      return first.Equals(second);
    }

    public static bool operator !=(Coordinate first, Coordinate second) {
      return !first.Equals(second);
    }
  }
}
